package com.horizon.manage.device.converter;

import com.horizon.common.converter.HorizonBaseEvdConverter;
import com.horizon.manage.device.dto.DeviceDto;
import com.horizon.manage.device.entity.Device;
import com.horizon.manage.device.vo.DeviceVO;
import org.springframework.stereotype.Component;

/**
 * 设备实体视图转换器.
 *
 * @author zhaoshb
 * @since 2022/12/4 21:08
 */
@Component
public class DeviceEvdConverter extends HorizonBaseEvdConverter<Device, DeviceVO, DeviceDto> {

    @Override
    public DeviceVO entityToVO(Device entity) {
        DeviceVO deviceVO = new DeviceVO();
        deviceVO.setId(entity.getId());
        deviceVO.setTenantId(entity.getTenantId());
        deviceVO.setDeviceType(entity.getDeviceType());
        deviceVO.setModel(entity.getModel());
        deviceVO.setManufacturers(entity.getManufacturers());
        deviceVO.setInstallTime(entity.getInstallTime());
        deviceVO.setSiteId(entity.getSiteId());
        return deviceVO;
    }

    @Override
    public Device dtoToEntity(DeviceDto dto) {
        Device device = new Device();
        device.setId(dto.getId());
        device.setSiteId(dto.getSiteId());
        device.setDeviceType(dto.getDeviceType());
        device.setTenantId(dto.getTenantId());
        device.setModel(dto.getModel());
        device.setManufacturers(dto.getManufacturers());
        device.setInstallTime(dto.getInstallTime());
        device.setStatus(dto.getStatus());
        return device;
    }
}
